<!--  -->
<template>
  <div class="cFloat bg">
        <div class="title">货栈</div>
        <el-header class="header" v-if="isShow">
          <el-dropdown class="right">
              <i class="el-icon-setting layoutIcon" ></i>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="layout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
          </el-dropdown>
          <span>匆匆那年</span>
        </el-header>
  </div>
</template>

<script>
export default {
  data () {
    return {
    }
  },

  components: {},

  computed: {
    isShow () {
      let user = this.$store.state.token
      if (user) {
        return true
      } else {
        return false
      }
    }
  },

  mounted () {
  },

  methods: {
    layout () {
      this.$confirm('此操作将退出该系统, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '退出成功!'
        })
        this.$store.commit('setToken', '')
        this.$router.push({path: '/login'})
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消退出'
        })
      })
    }
  }
}

</script>
<style lang='scss' scoped>
.bg{
  background: #263556;
  line-height: 60px;
  padding-left: 30px;
  font-size: 20px;
  font-weight: bold;
  color:#ffffff;
}
.title{
  float: left;
}
.header{
  float: right;
  text-align: right;
  font-size: 16px;
  line-height: 60px;
  .right{
    text-align: right;
    .layoutIcon{
      color: #ffffff;
      margin-right: 15px;
    }
  }
}
</style>
